<template>
  <div class="dashboard-container">
    <div class="app-container">
      <!-- 自定义组件，标题 -->
      <PageTitle :show-before="true">
        <template v-slot:before>
          <h2>招聘职位管理</h2>
        </template>
      </PageTitle>
      <el-row
        :gutter="10"
        type="flex"
        justify="space-between"
        style="margin-top: 20px"
      >
        <el-col :span="16">
          <el-row :gutter="10" type="flex">
            <el-col :span="4">
              <el-select placeholder="不限过期状态">
                <el-option
                  v-for="item in expireStatus"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-col>
            <el-col :span="4">
              <el-select placeholder="不限审核状态">
                <el-option
                  v-for="item in toExamineStatus"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-col>
            <el-col :span="4">
              <el-select placeholder="不限置顶状态">
                <el-option
                  v-for="item in topUpStatus"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-col>
            <el-col :span="4">
              <el-select placeholder="不限推荐状态">
                <el-option
                  v-for="item in recommendStatus"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="10">
          <el-row type="flex">
            <el-select placeholder="职位名称">
              <el-option
                v-for="item in positionName"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              >
              </el-option>
            </el-select>
            <el-row type="flex">
              <el-input placeholder="请输入搜索内容"></el-input>
              <el-button type="primary">
                <i class="el-icon-search"></i>
              </el-button>
            </el-row>
          </el-row>
        </el-col>
      </el-row>
      <!-- 数据表 -->
      <el-table
        v-loading="downloadLoading"
        ooltip-effect="dark"
        :data="list"
        max-height="500px"
        style="margin-top: 20px"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55" fixed />
        <el-table-column
          label="职位信息"
          align="center"
          width="150"
          prop="jobname"
          fixed
        ></el-table-column>
        <el-table-column
          label="联系人"
          align="center"
          prop="full_name"
          fixed
          width="150"
        >
          <template slot-scope="scope">
            <div>{{ scope.row.contact }}</div>
            <div>{{ scope.row.telephone }}</div>
          </template>
        </el-table-column>
        <el-table-column
          label="联系地址/信息描述"
          align="center"
          prop="phone"
          width="130"
          fixed
        >
          <template slot-scope="scope">
            <div>{{ scope.row.address }}</div>
            <div class="substsring">{{ scope.row.content }}</div>
          </template>
        </el-table-column>
        <el-table-column
          label="审核状态"
          align="center"
          prop="school"
          width="100"
        >
          <template slot-scope="scope">
            <el-tag type="success">{{ scope.row.audit_text }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          label="置顶"
          align="center"
          prop="qualification"
          width="100"
        >
          <template slot-scope="scope">
            <el-tag type="warning">{{ scope.row.top_text }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          label="推荐"
          align="center"
          prop="practice_sum"
          width="100"
        >
          <template slot-scope="scope">
            <el-tag type="warning">{{ scope.row.recommend_text }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          label="添加/到期时间"
          align="center"
          prop="com_name"
          width="150"
        >
          <template slot-scope="scope">
            <div>
              <i class="el-icon-time"></i>{{ scope.row.refreshtime_cn }}
            </div>
            <div><i class="el-icon-time"></i>{{ scope.row.endtime_cn }}</div>
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          align="center"
          prop="prop"
          label="刷新时间"
          width="140"
        >
          <template slot-scope="scope">
            {{ scope.row.refreshtime_cn }}
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          align="center"
          prop="prop"
          label="操作"
        >
          <template>
            <el-button type="primary" size="small" @click="editHire"
              >编辑</el-button
            >
            <el-button
              type="primary"
              size="small"
              @click="extensionDialog = true"
              >延期</el-button
            >
            <el-button
              type="primary"
              size="small"
              @click="changePasswordDialog = true"
              >改密</el-button
            >
            <el-button type="danger" size="small" @click="delBtn"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-row :gutter="10" style="margin-top: 20px">
        <el-col :span="8">
          <el-button type="primary" size="small" @click="addHire"
            >新增</el-button
          >
          <el-button type="warning" size="small" @click="examineDialog = true"
            >审核</el-button
          >
          <el-button type="primary" size="small" @click="topUpDialog = true"
            >置顶</el-button
          >
          <el-button type="primary" size="small" @click="recommendDialog = true"
            >推荐</el-button
          >
          <el-button type="primary" size="small">刷新</el-button>
          <el-button type="danger" size="small" @click="delBtnSelect"
            >删除所选</el-button
          >
        </el-col>
        <el-col :span="16">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage4"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="10"
            layout="total, sizes, prev, pager, next, jumper"
            :total="255"
            style="text-align: right"
          >
          </el-pagination>
        </el-col>
      </el-row>
    </div>
    <!-- 审核 -->
    <el-dialog
      title="将所选信息设置为"
      :visible.sync="examineDialog"
      width="25%"
    >
      <div>
        <el-form ref="form" :model="form" label-width="80px">
          <el-form-item label="审核状态">
            <el-radio-group v-model="model">
              <el-radio :label="label">待审核</el-radio>
              <el-radio :label="label">已通过</el-radio>
              <el-radio :label="label">未通过</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer">
        <el-button @click="examineDialog = false">取 消</el-button>
        <el-button type="primary">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 置顶 -->
    <el-dialog
      title="将所选信息设置为置顶"
      :visible.sync="topUpDialog"
      width="25%"
    >
      <div>
        <el-form ref="form" :model="form" label-width="80px">
          <el-form-item label="置顶状态">
            <el-radio v-model="radio" label="label">不置顶</el-radio>
            <el-radio v-model="radio" label="label">置顶</el-radio>
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer">
        <el-button @click="topUpDialog = false">取 消</el-button>
        <el-button type="primary">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 推荐 -->
    <el-dialog
      title="将所选信息设置为推荐"
      :visible.sync="recommendDialog"
      width="25%"
    >
      <div>
        <el-form ref="form" :model="form" label-width="80px">
          <el-form-item label="推荐状态">
            <el-radio v-model="radio" label="label">不推荐</el-radio>
            <el-radio v-model="radio" label="label">推荐</el-radio>
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer">
        <el-button @click="recommendDialog = false">取 消</el-button>
        <el-button type="primary">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 延期 -->
    <el-dialog
      title="将所选信息延期"
      :visible.sync="extensionDialog"
      width="25%"
    >
      <div>
        <el-form ref="form" :model="form" label-width="100px">
          <el-form-item label="有效期截止"> 2024-03-03 08:24</el-form-item>
          <el-form-item label="有效期延长">
            <el-input placeholder="" style="width: 70%"></el-input>天
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer">
        <el-button @click="extensionDialog = false">取 消</el-button>
        <el-button type="primary">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 改密 -->
    <el-dialog
      title="修改管理密码为"
      :visible.sync="changePasswordDialog"
      width="25%"
      :before-close="dialogBeforeClose"
    >
      <div>
        <el-form ref="form" :model="form" label-width="80px">
          <el-form-item label="管理密码">
            <el-input placeholder=""></el-input>
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer">
        <el-button @click="changePasswordDialog = false">取 消</el-button>
        <el-button type="primary">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      examineDialog: false,
      topUpDialog: false,
      recommendDialog: false,
      extensionDialog: false,
      changePasswordDialog: false,
      list: [
        {
          id: 1,
          audit: 1,
          is_top: 0,
          is_recommend: 0,
          jobname: "大饼九点要",
          comname: "下点卡点",
          contact: "上线",
          telephone: "13757434626",
          address: "一些事情",
          content:
            "2.07 复制打开抖音，看看【闲二的大饼的作品】NZP勉强够用，但是不强，甚至有点蠢，大饼九点要下... https:\/\/v.douyin.com\/iNftqCnE\/ 12\/03 qEh:\/ j@P.Kj",
          valid: 30,
          adminpwd: "e61e7de603852182385da5e907b4b232",
          addtime: 1708130613,
          refreshtime: 1708130613,
          endtime: 1710722613,
          click: 0,
          refreshtime_cn: "2024-02-17 08:43",
          addtime_cn: "2024-02-17 08:43",
          endtime_cn: "2024-03-18 08:43",
          audit_text: "已通过",
          recommend_text: "否",
          top_text: "否",
          content_:
            "2.07 复制打开抖音，看看【闲二的大饼的作品】NZP勉强够用，但是不强，甚至有点蠢，大饼九点要下... https:\/\/v.douyin.com\/iNftqCnE\/ 12\/03 qEh:\/ j@P.Kj",
        },
      ],
      expireStatus: [
        { id: 1, name: "不限过期状态" },
        { id: 2, name: "未过期" },
        { id: 3, name: "已过期" },
      ],
      toExamineStatus: [
        { id: 1, name: "不限过期状态" },
        { id: 2, name: "未过期" },
        { id: 3, name: "已过期" },
      ],
      toExamineStatus: [
        { id: 1, name: "不限审核状态" },
        { id: 2, name: "未审核" },
        { id: 3, name: "已通过" },
        { id: 4, name: "未通过" },
      ],
      topUpStatus: [
        { id: 1, name: "不限置顶状态" },
        { id: 2, name: "未置顶" },
        { id: 3, name: "已置顶" },
      ],
      recommendStatus: [
        { id: 1, name: "不限推荐状态" },
        { id: 2, name: "未推荐" },
        { id: 3, name: "已推荐" },
      ],
      positionName: [
        { id: 1, name: "职位名称" },
        { id: 2, name: "公司名称" },
        { id: 3, name: "具体描述" },
        { id: 4, name: "手机号" },
      ],
    };
  },
  methods: {
    addHire() {
      this.$router.push({
        name: "addHire",
      });
    },
    delBtnSelect() {
      this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    delBtn() {
      this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    editHire() {
      this.$router.push({
        name: "editHire",
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.substsring {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
</style>
